import {defHttp} from '/@/utils/http/axios';
import {Modal} from 'ant-design-vue';
import {useMethods} from '/@/hooks/system/useMethods';

const { handleExportXls } = useMethods();
enum Api {
  list = "/pay-service/bill/page",
  downloadBill = "/pay-service/bill/download",
  delete = "/pay-service/bill/deleteById",
  deleteBatch = "/pay-service/bill/deleteBatch",

  exportXls = "/system-service/config/exportXls",
}

/**
 * 导出url
 */
export const getExportUrl = Api.exportXls;


/**
 * 查询列表
 * @param params
 */
export const getList = (params) => {
  return defHttp.get({url: Api.list, params});
}

/**
 * 查询列表
 * @param params
 */
export const downloadBill = (params) => {
  // const url = setObjToUrlParams(
  //   Api.downloadBill as string, 
  //   Object.assign({}, params)
  // )
  // downloadByUrl({url})
  handleExportXls("微信对账单", Api.downloadBill, params)
}


/**
 * 删除退款
 * @param params
 */
export const deleteBill = (params, handleSuccess) => {
  return defHttp.delete({url: Api.delete, data: params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}

/**
 * 批量删除
 * @param params
 */
export const batchDeleteBill = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}

